﻿using System;
using System.Collections.ObjectModel;
using System.Globalization;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Markup;

namespace WinRT.SIP.UI.Converters
{
    [ContentProperty(Name = "Converters")]
    public class CollectionConverter : IValueConverter
    {
        ValueConverterCollection _converters;
        
        public ValueConverterCollection Converters
        {
            get { return _converters ?? (_converters = new ValueConverterCollection()); }
        }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            foreach (var valueConverter in Converters)
            {
                value = valueConverter.Convert(value, targetType, parameter, language);
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    public sealed class ValueConverterCollection : Collection<IValueConverter>
    {
    }
}
